/*
 * @Author: 彭林
 * @Date: 2021-05-14 15:15:56
 * @LastEditTime: 2021-07-14 17:59:09
 * @LastEditors: 彭林
 * @Description:
 * @FilePath: /saas-app/app/service/districts.go
 */
package service

import (
	"saas-app/app/dao"

	"github.com/gogf/gf/database/gdb"
)

type DistrictsRepository interface {
	GetDistrictsList(id uint) gdb.Result
}

type districts struct{}

func DistrictsService() DistrictsRepository {
	return &districts{}
}

func (d districts) GetDistrictsList(id uint) gdb.Result {
	if id == 0 {
		panic("参数错误")
	}
	dlist, err := dao.District.Where("parent_id = ?", id).FindAll()

	if err != nil {
		panic(err)
	}

	return dlist
}
